package com.mate.cloud.redisson.listener;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * 配套的监听器
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2025/9/13 14:31
 * @updateUser: MI
 * @updateTime: 2025/9/13 14:31
 * @updateRemark: 修改内容
 * @version: 1.0
 */
@Component
public class MyMsgSubscriber implements MessageListener {
    /*    @Autowired
        private  RedisTemplate redisTemplate;*/
    @Override
    public void onMessage(Message message, byte[] pattern) {
        // 处理收到的消息
        String channel = new String(message.getChannel()); // 消息来自哪个频道
        String body = new String(message.getBody());       // 消息内容
        System.out.println("收到来自 " + channel + " 的消息：" + body);
    }
}